#include <initializer_list>
#include <iostream>
#include <vector>
using namespace std;

class MyTestInitializer {
  public:
  MyTestInitializer(){}
     MyTestInitializer(int a) { cout << "constructor a=" << a << endl; }
    MyTestInitializer(int a, int b) {
        cout << "constructor a,b=" << a << "\t" << b << endl;
    }
    MyTestInitializer(const MyTestInitializer& obj) {
        cout << "copy constructor" << endl;
    }
     MyTestInitializer(int a, int b, int c) {
        cout << "constructor a,b,c=" << a << "\t" << b << c << endl;
    }
    //  MyTestInitializer(std::initializer_list<int> l) {
    //     cout << "initializer list:" << endl;
    //     for (auto i : l) {
    //         cout << i << " ";
    //     }
    //     cout << endl;
    // }
    MyTestInitializer& operator=(const MyTestInitializer &obj)
    {
        cout<<"operator="<<endl;
        return *this;
    }
};
template <typename T> void print(std::initializer_list<T> list) {
    for (auto i = list.begin(); i != list.end(); ++i) {
        cout << *i << " ";
    }
    cout << endl;
}
void printP(const MyTestInitializer &obj)
{

}
std::vector<int> func(void)
{
    int a = 10;
    int b = 11;
    return {a,b};
}

struct InitList{
    int a;
    int b;
    int c;
};
#include <algorithm>
#include <vector>

void testInitializerList() {

    MyTestInitializer m1(10);
    cout << "//////////m1////////////////////" << endl;
    MyTestInitializer m2 = 11;
    cout << "//////////m2////////////////////" << endl;

    MyTestInitializer m3{12};
    cout << "//////////m3////////////////////" << endl;

    MyTestInitializer m4={13, 14};
    cout << "//////////m4////////////////////" << endl;

    MyTestInitializer m5={15, 16, 17};
    cout << "//////////m5////////////////////" << endl;

    // MyTestInitializer m6{18, 19, 20, 21};
    cout << "//////////m6////////////////////" << endl;
    printP({12,34,56});
    print({1,2,3,4,5,6,7});

    // print(func());

    cout<<"////////////////////////////////////////"<<endl;

    struct InitList si{10};

    cout<<"print si:"<<si.a<<"\t"<<si.b<<"\t"<<si.c<<endl;


    // MyTestInitializer m1 = 10;
    // MyTestInitializer m2(11,12);
    // MyTestInitializer m3{13,14,15};
    // MyTestInitializer m4{16,17,18,19};
    // MyTestInitializer m5={21};

    // auto i = [](int x)->bool{
    //     return x<5;
    // };

    // cout<<i(4)<<endl;

    int a;
    int b{};
    int *p;
    int *q{};

    int x1(5);
    int x2 = 6;
    int x3{3};
    double x4={5};
    std::vector<int> v1{1,2,3,4,5};
    std::vector<int> v2{1,2,3,48888888};
    float d{4};
    cout<<a<<"\t"<<b<<"\t"<<p<<"\t"<<q<<endl;
    cout<<x1<<"\t"<<x2<<"\t"<<x3<<"\t"<<x4<<endl;

    print({1,2,3,4,5,6,7,9,11});

    int mx = std::max({1,23,4,5,678,11,34});
    cout<<"mx value:"<<mx<<endl;
}